package com.wjjun.library.binding;

import androidx.databinding.BindingAdapter;

import com.wjjun.library.adpter.BannerImageAdapter;
import com.youth.banner.Banner;
import com.youth.banner.listener.OnBannerListener;

import java.util.List;

/**
 * author : wangjunjun
 * date   : 2021/8/16
 * desc   :
 */
public class BannerAdapter {

    @BindingAdapter(value = {"bannerList"}, requireAll = false)
    public static void bindAdapter(Banner banner, List<String> list) {
        if (banner.getAdapter() == null) {
            banner.setAdapter(new BannerImageAdapter(banner.getContext(), list));
        } else {
            banner.setDatas(list);
        }
    }

    @BindingAdapter(value = "bannerClickListener")
    public static void setOnBannerListener(Banner banner, OnBannerListener bannerListener) {
        if (bannerListener != null) {
            banner.setOnBannerListener(bannerListener);
        }
    }
}
